package test

import (
	"gm/app/model/model"
)

type Play_active_manage_conf_copy struct {
	ID        int    `json:"id" gorm:"index"`
	Name  string `json:"name"`
	Money string `json:"money"`
}

type Out struct {
	Mess  interface{}
	Name  string `json:"cname"`
	Money  string
}

type TestService struct {


}
/*
socket推送测试使用
*/
func  (this *TestService) GetData(id int) (Out, error) {
	var user []*Play_active_manage_conf_copy
	err := model.DB.Select("id, name,money").Where("id = ? AND enable = ? ", id, 1).Find(&user).Error
	if err != nil {
		return Out{}, err
	}

	var result = Out{}
	result.Mess = user
	result.Name = "测试大厅"
	result.Money = "活动资金"
	return result, nil
}


func (this *TestService) AddData(name string, money int) error {
	p := Play_active_manage_conf_copy{
		Name:  name,
		Money:  string(money),
	}
	if err := model.DB.Create(&p).Error; err != nil {
		return err
	}
	return nil
}

func (this *TestService) UptData(id int, data interface{}) error {

	if err := model.DB.Model(&Play_active_manage_conf_copy{}).Where("id = ?", id).Updates(data).Error; err != nil {
		return err
	}

	return nil
}

func (this *TestService) DelData(id int) error {
	if err := model.DB.Where("id = ?", id).Delete(&Play_active_manage_conf_copy{}).Error; err != nil {
		return err
	}

	return nil
}


